package Registration;

import java.sql.ResultSet;
import java.sql.SQLException;

import dbmanager.DBManager;

public class duplicateRecordInProperty 
{
	DBManager db;
	public duplicateRecordInProperty(DBManager db) 
	{
		this.db = db;
	}
	
	void RemoveRecordFromProperty()
	{
		try 
		{
			ResultSet rs = db.getSelect("select * from property_details");
			while(rs.next())
			{
				String id = rs.getString("id");
				ResultSet rs1 = db.getSelect("select * from property_details where id='"+id+"'");
				try
				{
					rs1.next();
					String id1 = rs1.getString("id");
					db.getDelete("delete  from property_details where mid ='"+rs.getString("mid")+"'"+"and pid='"+rs.getString("pid")+"' and pv ='"+rs.getString("pv")+"' and vt='"+rs.getString("VT")+"'"+" and Ref='"+rs.getString("Ref")+"' and id!="+id1);
				}
				catch (Exception e) 
				{
					e.printStackTrace();
				}
			}
		}
		catch (SQLException e) 
		{
			
		}
	}
	
	public static void main(String[] args) 
	{	
		DBManager db = new DBManager();
		db.getConnect();
		duplicateRecordInProperty dr = new duplicateRecordInProperty(db);
		dr.RemoveRecordFromProperty();
	}
}
